﻿//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Licensed under the MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once

#include "GbmpModel.h"
#include "ILevelHeaderBehavior.h"
#include "DbDataSchema.h"

namespace gcmp
{
    class IGraphicsText;
    class IElement;

    enum class LevelTriangleHeaderType : int32_t
    {
        NoHeader = 0,    //没有标头
        UpperHeader = 1, //上标头(默认)
        LowerHeader = 2, //下标头
    };

    class GBMP_MODEL_EXPORT LevelTriangleHeaderBehavior : public NdbObjectSchematic, public ILevelHeaderBehavior
    {
        DBOBJECT_DATA_BEGIN_AND_QUICK_CAST_FROM(gcmp, LevelTriangleHeaderBehavior, gcmp::NdbObjectSchematic, 8E506D39 - D40F - 49D5 - A552 - 0F3AA7BEFBBD, gbmpmodel, gcmp::ILevelHeaderBehavior)
            // IExternalObject所需的属性， 暂时都用默认的
            DATA_TRANSIENT(IElement*, pOwnerElement)
            DATA(LevelTriangleHeaderType, HeaderType)
        DBOBJECT_DATA_END
    public:
        virtual OwnerPtr<IGraphicsNodeGroup> CreateLevelHeader(const Vector3d& symbolPos, const Vector3d& symbolDir, const Vector3d& texDir, double height, double viewScale) const override;

    public:
        virtual OwnerPtr<IParameter> GetNativeParameter(int parameterId) const override;
        virtual bool SetNativeParameter(const IParameter *parameter, std::wstring* errorMessage = nullptr) override;
        virtual void ReportParameterDefinitions(std::vector<int>* parameterIds) const override;
        virtual bool IsParameterModifiable(int parameterId) const override;

    public: 
        LevelTriangleHeaderType GetHeaderType() const { return GetHeaderType__(); }

    public:
        virtual bool SetOwnerElement(IElement* pOwnerElement) override;
        virtual IElement* GetOwnerElement() override;
        virtual const IElement* GetOwnerElement() const override;

    public: //实现NdbObject接口
        virtual NdbObject* GetTopOwnerObject() const override;

    private:
        IDocument* GetDocument() const;
        OwnerPtr<IGraphicsText> CreateElevationText(const std::wstring& heightTex, double height, const Vector3d& texPos, const Vector3d& texDir, const Vector3d& texNor, double viewScale, bool isViewLeft) const;
        OwnerPtr<IGraphicsText> CreateSignText(const Vector3d& signPos, const Vector3d& texDir, const Vector3d& texNor, double viewScale, bool isViewLeft) const;
    };

}// namespace gcmp
